package com.jeesite.modules.stock.web;

import java.util.Map;

import com.jeesite.modules.stock.dto.vo.SectorRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.jeesite.common.entity.Page;
import com.jeesite.modules.stock.dto.SectorDateRangeRankSearchDTO;
import com.jeesite.modules.stock.dto.SectorSearchDTO;
import com.jeesite.modules.stock.dto.vo.StockHistoryDataVO;
import com.jeesite.modules.stock.service.SectorDailyService;
import com.jeesite.modules.stock.service.SectorsService;

@RestController
@RequestMapping("${adminPath}/sector")
public class SectorController {
	
	@Autowired
	private SectorDailyService sectorDailyService;
	
	@Autowired
	private SectorsService sectorsService;

	/**
	 * 分页查询板块数据
	 * 
	 * @param searchDTO 查询参数
	 * @return
	 */
	@PostMapping("getSectors")
	@ResponseBody
	public Page<Map<String, Object>> getSectors(@RequestBody SectorSearchDTO searchDTO){
		return sectorDailyService.findPage(searchDTO);
	}
	
	/**
	 * 根据板块名称查询板块数据
	 * @param sectorName
	 * @return
	 */
	@GetMapping("getSectorByName")
	public SectorRecord getSectorByName(String sectorName) {
		return sectorsService.findDataBySectorName(sectorName);
	}
	
	/**
	 * 板块区间排名
	 * 
	 * @param searchDTO 查询参数
	 * @return
	 */
	@PostMapping("getSectorOfDateRange")
	@ResponseBody
	public Page<StockHistoryDataVO> getSectorOfDateRange(@RequestBody SectorDateRangeRankSearchDTO searchDTO) {
		return sectorDailyService.findDateRangeRank(searchDTO);
	}
	
	
}
